package com.ch.playandroid.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import coil.load
import com.ch.playandroid.bean.Data
import com.youth.banner.adapter.BannerAdapter


class AppBannerAdapter(private val layoutResId: Int, listData: List<Data>) :
    BannerAdapter<Data, ImageViewViewHolder>(listData) {

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): ImageViewViewHolder {
        val itemView = LayoutInflater.from(parent?.context).inflate(layoutResId, parent, false)
        return ImageViewViewHolder(itemView)
    }

    override fun onBindView(holder: ImageViewViewHolder?, data: Data?, position: Int, size: Int) {
        val imageView: ImageView? = holder?.imageView
        imageView?.run {
            load(data?.imagePath)
        }
    }
}